package io.github.tangwan.designpattern.creational.singleton;

/**
 * 饿汉
 * @author tangwan
 * @version V1.0
 * created on 2021/9/27 11:16
 * @since JDK 1.8
 */
public class Singleton3 {

    //创建 SingleObject 的一个对象
    private static Singleton3 instance = new Singleton3();

    //让构造函数为 private，这样该类就不会被实例化
    private Singleton3(){}

    //获取唯一可用的对象
    public static Singleton3 getInstance(){
        return instance;
    }

    public void showMessage(){
        System.out.println("Hello World!");
    }

}
